#!/usr/bin/env ruby

LKP_SRC ||= ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require 'set'
require "#{LKP_SRC}/lib/common"

error_ids = Set.new
in_stderr = false
seqno = ''

while (line = STDIN.gets)
  case line.chomp!
  when /^## ______________([0-9.]+):stderr$/
    in_stderr = true
    seqno = $1
    next
  when /^## ______________#{seqno}:enderr$/
    in_stderr = false
    seqno = ''
  end
  next unless in_stderr
  next unless line.downcase =~ /(error|warning):[^:]/

  error_ids << build_pkg_error_id(line)
end

error_ids.each do |id|
  puts id + ': 1'
end
